﻿using System;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;

using LTJ.Common;
using LTJ.Config;
using LTJ.FrameWork;

namespace uswinweb.admin
{
    public partial class managemain : System.Web.UI.MasterPage
    {
        protected DataTable maindt = new DataTable();
        protected DataTable subdt = new DataTable();
        public string pagename = "";
        protected string currentParentLink = "";
        protected string currentMainmenu = "";
        protected string currentSubmenu = "";
        protected string extendstr = "";

        /// <summary>
        /// 导航扩展
        /// </summary>
        public string ExtendStr
        {
            set { extendstr = value; }
            get { return extendstr; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            maindt = Caches.GetAdminMenu(LTJ.Entity.UserMenuType.MainMenu);
            subdt = Caches.GetAdminMenu(LTJ.Entity.UserMenuType.SubMenu);
            pagename = SASRequest.GetPageName();            

            if (pagename != "index.aspx")
            {
                string currentParentid = "";
                currentSubmenu = subdt.Select("menulink = '" + pagename + "'").Length > 0 ? subdt.Select("menulink = '" + pagename + "'")[0]["menutitle"].ToString() : "";
                currentParentid = subdt.Select("menulink = '" + pagename + "'").Length > 0 ? subdt.Select("menulink = '" + pagename + "'")[0]["parentid"].ToString() : "";
                currentParentLink = subdt.Select("parentid = '" + currentParentid + "'").Length > 0 ? subdt.Select("parentid = '" + currentParentid + "'")[0]["menulink"].ToString() : "";

                if (currentParentid != "")
                {
                    currentMainmenu = maindt.Select("menuid = '" + currentParentid + "'").Length > 0 ? maindt.Select("menuid = '" + currentParentid + "'")[0]["menutitle"].ToString() : "";
                }
            }

            this.Page.Title = currentMainmenu + " - " + currentSubmenu;
        }
    }
}